package gitobject;
import Utils.tempWorkTree;
import core.JitAdd;
import repository.Repository;
import zlib.ZLibUtils;

import java.io.*;


public class GitObject implements Serializable{

    protected String fmt;                  //type of object
    protected String key;                  //key of object
    protected String mode;                 //mode of object
    protected String path = tempWorkTree.gitDir+File.separator+"objects";         //absolute path of objects

    public String getFmt(){
        return fmt;
    }
    public String getKey() { return key; }
    public String getMode(){
        return mode;
    }
    public String getPath() {
        return path;
    }


    public GitObject(){}
    /**
     * Get the value(content) of file
     * @param file
     * @return String
     * @throws IOException
     */

    /**
     * 灏嗗璞″簭鍒楀寲鍒版湰鍦颁粨搴撲腑
     * @throws Exception
     */

// writeObject类
    public void writeObject() throws IOException {
        String name=this.getKey();
        ObjectOutputStream objectOutputStream=null;
        try {
            objectOutputStream = new ObjectOutputStream(new FileOutputStream(this.getPath() + File.separator + this.getKey()));
            objectOutputStream.writeObject(this);
        }catch (Exception e){
            throw new RuntimeException(e);
        }finally {
            objectOutputStream.close();
        }
    }
    /**
     * 搴忓垪鍖栧璞＄劧鍚庝娇鐢▃lib鍘嬬缉鏂囦欢,鍘嬬缉鍐欏叆
     * @throws Exception
     */
    public void compressWrite() throws Exception{

    }
}
